package cn.com.roy.thread.t3_1_13.pipereaderwriter;

import java.io.IOException;
import java.io.PipedReader;
import java.io.PipedWriter;

public class ReadData {

    public void readData(PipedReader pipedReader){
        System.out.println("Read :");
        try {
            char[] chars = new char[20];
            int readLength = pipedReader.read(chars);
            while (readLength != -1){
                String newData = new String(chars,0,readLength);
                System.out.println(newData);
                readLength = pipedReader.read(chars);
            }
            System.out.println();
            pipedReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
